#!/bin/sh
DJANGO_DIR="${HOME}/django"
TMP_DIR="/tmp"
PROJ_DIR="django-buildbot"

set -x

cd ${DJANGO_DIR}
svn up
${PYTHON} setup.py install

cd ${TMP_DIR}
rm -rf ${PROJ_DIR}
mkdir ${PROJ_DIR}
cd ${PROJ_DIR}
${PYTHON_BIN_PATH}/django-admin.py startproject myproject
cd myproject
cp settings.py settings.py.orig
sed -e "s/^DATABASE_ENGINE.*$/DATABASE_ENGINE = 'sqlite3'/g" \
    -e "s/^DATABASE_NAME.*$/DATABASE_NAME = ':memory:'/g" \
    < settings.py.orig > settings.py

PYTHONPATH=$PYTHONPATH:${TMP_DIR}/${PROJ_DIR}
export PYTHONPATH

cd ${DJANGO_DIR}/tests
${PYTHON} runtests.py --verbosity=2 --settings=myproject.settings
